<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        ~ function() {
            var pro = Array.prototype;
            pro.myDistinct = function() {
                var obj = {};
                for (var i = 0; i < this.length; i++) {
                    var item = this[i];
                    if (typeof obj[item] !== 'undefined') {
                        this[i] = this[this.length - 1];
                        this.length--;
                        i--;
                        continue;
                    }
                    obj[item] = item;
                }
                obj = null;
                return this;
            }
        }();
        var arr = [1, 2, 3, 4, 5, 6, 6, 7, 7, 8, 1, 2, 3, 1];
        console.log(arr.myDistinct());
    </script>
</body>

</html>